@mainColor: #fb7299;

* {
    padding: 0;
    margin: 0;
}

body,
.navbar,
ul {
    display: flex;
    justify-content: center;
    align-items: center;
}

body {
    height: 100vh;
    background: linear-gradient(200deg,#ddd6f3,#faaca8);
}

.navbar {
    position: relative;
    height: 50px;
    background-color: aliceblue;
    border-radius: 25px;

    input {
        height: 50px;
        width: 50px;
        opacity: 0;
        cursor: pointer;

        &:checked~ul {
            width: 280px;
            // transition: all .5s;
        }

        &:checked~span:nth-of-type(1) {
            top: 50%;
            transform: rotate(-45deg);
            background-color: @mainColor;
            transition: transform .5s ease-out,top .5s ease-out;
        }

        &:checked~span:nth-of-type(2) {
            top: 50%;
            transform: rotate(45deg);
            background-color: @mainColor;
            transition: transform .5s ease-out,top .5s ease-out;
        }
    }

    ul {
        width: 0;
        list-style: none;
        white-space: nowrap;
        overflow: hidden;
        transition: width .5s;
        li {
            margin: 10px 5px;

            a {
                text-decoration: none;

                &:hover {
                    color: @mainColor;
                }
            }
        }
    }

    span {
        position: absolute;
        left: 8px;
        top: 50%-10px;
        height: 4px;
        width: 35px;
        background-color: #6666;
        /* 现在span覆盖着复选框，鼠标放到span上是点不中复选框的，下面这个属性就可以解决这个问题，即便鼠标放到span上点击也能选中或取消选中复选框 */
        pointer-events: none;
        transition: transform 0.5s ease-in-out,top 0.5s ease-in-out 0.5s;
        &:nth-of-type(2) {
            top: 50%+10px;
        }
    }
}